CPS transformation of flow information , Part II : administrative reductions ∗ DANIEL
نویسندگان
چکیده
We characterize the impact of a linear β-reduction on the result of a control-flow analysis. (By ‘a linear β-reduction’ we mean the β-reduction of a linear λ-abstraction, i.e., of a λabstraction whose parameter occurs exactly once in its body.) As a corollary, we consider the administrative reductions of a Plotkin-style transformation into Continuation-Passing Style (CPS), and how they affect the result of a constraint-based control-flow analysis and, in particular, the least element in the space of solutions. We show that administrative reductions preserve the least solution. Preservation of least solutions solves a problem that was left open in Palsberg and Wand’s article ‘CPS Transformation of Flow Information.’ Together, Palsberg and Wand’s article and the present article show how to map in linear time the least solution of the flow constraints of a program into the least solution of the flow constraints of the CPS counterpart of this program, after administrative reductions. Furthermore, we show how to CPS transform control-flow information in one pass. 1 Background and introduction Since their inception, over 30 years ago (Reynolds, 1993), continuations and the transformation into Continuation-Passing Style (CPS) have been the topic of much study, ranging from semantics and logic to implementations of sequential, concurrent, and distributed programming languages and systems. Fifteen years ago, Meyer and Wand (Meyer & Wand, 1985; Wand, 1985) noticed that the CPS transformation preserves types and they constructed a CPS transformation of types. type CPS transformation of types type direct-style program type inference CPS transformation of terms CPS program type inference ∗ This work was carried out while the first author was at BRICS. Basic Research in Computer Science (www.brics.dk), funded by the Danish National Research Foundation. 926 D. Damian and O. Danvy Over the last couple of years, Palsberg and Wand have extended this observation to flow types and the flow information gathered by a control-flow analysis (Palsberg & Wand, 2002), designing a CPS transformation of flow information. flow information CPS transformation of flow flow information direct-style program flow analysis CPS transformation of terms CPS program flow analysis Independently, and with a different motivation, we have also designed a CPS transformation of flow information for control flow and binding times (Damian, 2001; Damian & Danvy, 2000; Damian & Danvy, 2002). The two CPS transformations of flow information correspond to two different takes on the CPS transformation of λ-terms: CPS with administrative redexes administrative reductions direct style CPS transformation transformation into monadic style CPS without administrative redexes monadic normal form introduction of continuations The CPS transformation is Plotkin’s (1975). It is a first-order, compositional rewriting system generating numerous administrative redexes that need to be postreduced in practice (Steele, 1978). Alternatively (Hatcliff & Danvy, 1994; Sabry & Wadler, 1997), the CPS transformation can be staged into a transformation into monadic normal form followed by an introduction of continuations. The two CPS transformations of flow information can be depicted as follows: CPS with administrative redexes this work direct style Palsberg & Wand, 2002 Damian & Danvy, 2002 CPS without administrative redexes monadic normal form Damian & Danvy, 2000 Palsberg and Wand show how to construct in linear time the flow information corresponding to a CPS program obtained through a Plotkin-style CPS transformation (Palsberg & Wand, 2002; Plotkin, 1975). The resulting programs contain all administrative redexes induced by Plotkin’s transformation. Therefore, CPS transformation of flow information, Part II: administrative reductions 927 e ∈ Exp ::= x | n | e 1 1 e 2 2 | if0 e e 0 0 e 1 1 | λx.e π ∈ Lam (λ-abstraction labels) ∈ Lab (term labels) n ∈ Lit (integer literals) Fig. 1. The language of labelled λ-terms. the corresponding CPS information of flow also contains spurious information which accounts for the extraneous λ-abstractions and their flow. The problem of eliminating this spurious information is open. Damian and Danvy show how to construct in linear time the flow information corresponding to the introduction of continuations, starting from monadic normal forms (Damian & Danvy, 2000; Hatcliff & Danvy, 1994). They also show how to construct in linear time the flow information corresponding to the transformation into monadic normal forms (Damian, 2001; Damian & Danvy, 2002). In this work, we complete the picture above by showing how to perform in linear time administrative reductions on CPS-transformed programs (Section 4). Our result hinges on linear reductions (Section 3). But first, we present the source language and a constraint-based control-flow analysis (Section 2).
منابع مشابه
CPS transformation of flow information, Part II: administrative reductions
We characterize the impact of a linear β-reduction on the result of a control-flow analysis. (By “a linear β-reduction” we mean the β-reduction of a linear λ-abstraction, i.e., of a λ-abstraction whose parameter occurs exactly once in its body.) As a corollary, we consider the administrative reductions of a Plotkinstyle transformation into continuation-passing style (CPS), and how they affect t...
متن کاملOn Static and Dynamic Control-Flow Information in Program Analysis and Transformation
This thesis addresses several aspects of static and dynamic control-flow information in programming languages, by investigating its interaction with program transformation and program analysis. Control-flow information indicates for each point in a program the possible program points to be executed next. Control-flow information in a program may be static, as when the syntax of the program dire...
متن کاملA Simple CPS Transformation of Control-Flow Information
We build on Danvy and Nielsen’s first-order program transformation into continuation-passing style (CPS) to design a new CPS transformation of flow information that is simpler and more efficient than what has been presented in previous work. The key to simplicity and efficiency is that our CPS transformation constructs the flow information in one go, instead of first computing an intermediate r...
متن کاملA Higher-Order Colon Translation
A lambda-encoding such as the CPS transformation gives rise to administrative redexes. In his seminal article “Call-by-name, call-by-value and the lambda-calculus”, 25 years ago, Plotkin tackled administrative reductions using a so-called colon translation. In “Representing control, a study of the CPS transformation”, 15 years later, Danvy and Filinski integrated administrative reductions in th...
متن کاملBack to Direct Style II :
We continue to investigate the direct-style transformation by extending it to programs requiring call-with-current-continuation (a.k.a. call/cc). The direct style (DS) and the continuation-passing style (CPS) transformations form a Galois connection. This pair of functions has a place in the programmer's toolbox | yet we are not aware of the existence of any other DS transformer. Starting from ...
متن کامل